<template>
  <div class="home-container">
    <topnav :userinfo="userinfo"></topnav>
    <div class="header">
      <div class="header-container">
        <div class="logo">
          <div
            title="我的淘宝"
            href="//i.taobao.com/my_taobao.htm?nekot=1470211439696&amp;tracelog=newmytb_logodianji"
            class="tblogo"
          ></div>
        </div>
        <div class="nav">
          <ul class="nav-left">
            <li class="index">首页</li>
            <li>账户设置</li>
          </ul>
          <div class="nav-right">
            <el-input placeholder="请输入内容" v-model="input2">
              <template slot="append"> 搜索 </template>
            </el-input>
          </div>
        </div>
      </div>
    </div>
    <div class="main-body-container">
      <div class="main-body">
        <userAside></userAside>
        <!-- <div class="nav-container">
          <dt class="main-body-title">全部功能</dt>
          <dd>我的购物车</dd>
          <dd>已买到的宝贝</dd>
          <dd>购买过的店铺</dd>
          <dd>我的发票</dd>
          <dd>我的收藏</dd>
          <dd>我的积分</dd>
          <dd>我的优惠信息</dd>
          <dd>评价管理</dd>
          <dd>退款维权</dd>
          <dd>我的足迹</dd>
          <dd>流量钱包</dd>
        </div> -->
        <div class="content-container">
          <div class="main-wrap">
            <div class="userBar">
              <div class="userInfo">
                <div class="basicInfo">
                  <div class="avatar" @mouseenter="editAvatar = true" @mouseleave="editAvatar = false">
                    <img :src="userDetail.userPic" alt="" />
                    <div class="mask" v-if="editAvatar">
                        <span>编辑资料</span>
                    </div>
                </div>
                  <div class="detail">
                    <span>{{userDetail.nickname}}</span><br />
                    <i class="iconfont">&#xe647;</i>
                  </div>
                </div>
                <ul class="stuffs">
                  <li>我的收货地址</li>
                  <li>我的优惠信息</li>
                  <li>我的支付宝</li>
                </ul>
              </div>
              <ul class="content">
                <li>待付款 <span>{{orderStatus.ispay}}</span></li>
                <li>待发货<span>{{orderStatus.todeliver}}</span></li>
                <li>待收货<span>{{orderStatus.isdeliver}}</span></li>
                <li>待评价</li>
                <li>退款</li>
              </ul>
            </div>
            <div class="goodsBar">
              <div class="title"><i class="iconfont">&#xe75f;</i>我的物流</div>
              <ul class="goodsContainer">
                <li class="goodsItem" v-for="(item,index) in orderList" :key="index">
                  <img :src="`http://127.0.0.1:3007/${item.picName}`" alt="" />
                  <div class="info" v-if="item.is_pay == 1 && item.is_deliver == 1">
                    <span class="status"
                      >您的快件已签收，签收人：同事（温馨提示您：戴口罩取快递，个您的快件已签收，签收人：同事（温馨提示您：戴口罩取快递，个您的快件已签收，签收人：同事（温馨提示您：戴口罩取快递，个</span
                    >
                    <span class="date">2022-09-26 11:57:43 查看物流明细</span>
                  </div>
                  <div class="info" v-if="item.is_pay == 1 && item.is_deliver == 0">
                    <span class="status"
                      >受当地疫情影响，快递收发受到一定的影响，请您耐心等待</span
                    >
                    <span class="date">2022-09-26 11:57:43</span>
                  </div>
                  <div class="info" v-if="item.is_pay == 0">
                    <span class="status"
                      >订单将于后关闭，请尽快付款</span
                    >
                    <span class="date">2022-09-26 11:57:43</span>
                  </div>
                  <el-button class="confirmbtn" v-if="item.is_pay == 1 && item.is_deliver == 1">确认收货</el-button>
                  <el-button class="confirmbtn" v-if="item.is_pay == 1 && item.is_deliver == 0">催发货</el-button>
                  <el-button class="confirmbtn" v-if="item.is_pay == 0 ">待支付</el-button>
                </li>
              </ul>
            </div>
          </div>
          <div class="calendar-right">
            <div class="calendar-title">我的日历</div>
            <div class="calendar-body">
              <span class="day">{{day}}</span>
              <span class="week">{{week}}</span>
              <span class="date">{{year}}.{{month}}</span>
            </div>
            <div class="recommend">
              <img src="@/assets/images/recommend.jpg" alt="" />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import topnav from '@/components/topnav.vue'
import userAside from '@/components/userAside.vue'
export default {
  components: {
    topnav,
    userAside
  },
  data () {
    return {
      editAvatar: false,
      userinfo: {},
      year: '',
      month: '',
      day: '',
      week: '',
      userDetail: {},
      showmenu: false,
      input2: '',
      orderStatus: {},
      orderList: []

    }
  },
  created () {
    this.getNowDate()
    this.getUserInfo()
  },
  mounted () {
    this.getTimeInterval()
  },
  computed: {},
  methods: {
    async getUserInfo () {
      const { data: res } = await this.$http.get('/user/getUserInfo')
      if (res.code !== 200) return this.$message.error('获取用户信息失败！')
      this.userinfo = res.data
      this.getDetail(this.userinfo.id)
      this.getOrderStatus()
      this.getOrderList()
    },
    getNowDate () {
      const timeOne = new Date()
      this.year = timeOne.getFullYear()
      this.month = timeOne.getMonth() + 1
      this.day = timeOne.getDate()
      this.month = this.month < 10 ? '0' + this.month : this.month
      this.day = this.day < 10 ? '0' + this.day : this.day
      this.week = timeOne.getDay()
      const weeks = ['日', '一', '二', '三', '四', '五', '六']
      this.week = '星期' + weeks[this.week]
    },
    async getDetail (id) {
      const { data: res } = await this.$http.post('/user/shopUserDetail', { id: id })
      if (res.code !== 200) return this.$message.error(res.msg)
      this.userDetail = res.data
      if (this.userDetail.userPic === null) {
        this.userDetail.userPic = '@/assets/images/user.png'
      } else {
        this.userDetail.userPic = `http://127.0.0.1:3007/${this.userDetail.userPic}`
      }
    },
    async getOrderStatus () {
      const { data: res } = await this.$http.post('/order/getOrderStatus', {
        id: this.userinfo.id
      })
      if (res.code !== 200) {
        return this.$message.error(res.msg)
      }
      this.orderStatus = res.data
    },
    async getOrderList () {
      const { data: res } = await this.$http.post('/order/getOrderExpress', { id: this.userinfo.id })
      if (res.code !== 200) {
        return this.$message.error(res.msg)
      }
      this.orderList = res.data
    },
    getTimeInterval (createTime) {
      // const timeNow = this.$moment().format('YYYY-MM-DD HH:mm:ss')
      // let timer = this.$moment(timeNow).diff(this.$moment('2022-09-19 00:00:00')) / 1000
      console.log()
    }

  }
}
</script>
<style lang="less" scoped>
.home-container {
  height: 100%;
  width: 100%;

}
.header {
  height: 60px;
  background: #ff4401;
  padding: 12px 0;
  position: relative;
  z-index: 5;
  border-bottom: 1px #e7e7e7 solid;

  .header-container {
    width: 1200px;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    display: flex;
    .logo {
      width: fit-content;
      display: flex;
      align-items: center;
      height: 100%;
      .tblogo {
        width: 140px;
        height: 36px;
        display: inline-block;
        vertical-align: middle;
        background-image: url(//img.alicdn.com/tps/i2/T1KNKSFldbXXcEPB2X-140-34.png);
        background-image: -webkit-image-set(url(//img.alicdn.com/tps/i4/T1IraRFjVcXXcEPB2X-140-34.png) 1x,url(//img.alicdn.com/tps/i1/T1KXqHFbdbXXaqVtDA-280-62.png) 2x);
        background-repeat: no-repeat;
        background-position: left center;
      }
    }
    .nav {
      margin-left: 20px;
      padding-left: 20px;
      display: flex;
      align-items: center;
      width: calc(100% - 160px);
      justify-content: space-between;
      .nav-left {
        height: 60px;
        display: flex;
        line-height: 60px;
        li {
          cursor: pointer;
          z-index: 1;
          margin-right: 15px;
          color: #fff;
          position: relative;
          &:hover:before{
            content: "";
            height: 0px;
            width: 0px;
            position: absolute;
            border: 8px solid #000;
            border-bottom-color:#fff ;
            border-right-color: transparent;
            border-left-color: transparent;
            border-top-color: transparent;
            bottom: 0;
            right: 20%;
          }
        }
      }
      .nav-right {
      }
    }
  }
}
.main-body-container {
  //   position: relative;
  height: auto;
  width: 100%;
  .main-body {
    width: 1200px;
    // position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    padding-top: 25px;
    padding-bottom: 40px;
    display: flex;
    .nav-container {
      padding-left: 3px;
      dd {
        font-size: 13px;
        line-height: 28px;
        margin: 5px 10px 1px 0;
        color: rgba(0, 0, 0, 0.85);
        cursor: pointer;
        &:hover {
          color: #f40;
        }
      }

      .main-body-title {
        color: #f40;
      }
    }
    .content-container {
      display: flex;
      flex: 1;
      justify-content: space-between;
      .main-wrap {
        width: 726px;
        margin-left: 10px;

        .userBar {
          border: 1px solid #e4eaee;
          .userInfo {
            color: #546d7e;
            padding: 10px;
            display: flex;
            background: #f5f8fa;
            border-bottom: 1px solid #e4eaee;
            .basicInfo {
              width: 39%;
              padding-left: 10px;
              display: flex;
              .avatar {
                width: 52px;
                height: 52px;
                border-radius: 50%;
                background: #fff;
                position: relative;
                overflow: hidden;
                cursor: pointer;
                img{
                    width: 100%;
                    height: 100%;
                }
                .mask{
                    position: absolute;
                    top: 0;
                    height: 100%;
                    width: 100%;
                    border-radius: 50%;
                    background: rgba(0, 0, 0, 0.45);
                    color: #fff;
                    font-size: 8px;
                    display: flex;
                    align-items: center;
                    justify-content: center;

                }
              }
              .detail {
                margin-left: 20px;
                margin-top: 6px;

                span {
                  font-size: 14px;
                  font-weight: 700;
                  cursor: pointer;
                  &:hover {
                    color: #f40;
                  }
                }
                line-height: 23px;
                display: block;
                color: #000;
                .iconfont {
                  color: #f40;
                  cursor: pointer;
                }
              }
            }
            .stuffs {
              display: flex;
              width: 61%;
              margin-right: -1px;
              margin-top: 9px;
              li {
                width: 33%;
                padding: 10px 0;
                color: #546d7e;
                text-align: center;
                cursor: pointer;
                font-size: 12px;
                &:hover {
                  color: #f40;
                }
              }
            }
          }
          .content {
            width: 100%;
            display: flex;
            li {
              height: 52px;
              line-height: 52px;
              width: 20%;
              text-align: center;
              font-size: 12px;
              color: #546d7e;
              position: relative;
              cursor: pointer;
              &:hover {
                color: #f40;
              }
              span{
                color: #f40;
                margin-left:10px;
                vertical-align: top;
              }
            }
            li:not(:last-child) {
              &::after {
                content: "";
                position: absolute;
                height: 18px;
                right: -5px;
                top: 30%;
                border-left: 1px solid #e4eaee;
              }
            }
          }
        }
        .goodsBar {
          margin-top: 23px;
          width: 100%;
          border: 1px solid #e4eaee;
          //   border: 1px solid red;
          .title {
            padding: 10px;
            background: #f5f8fa;
            line-height: 23px;
            color: #546d7e;
            border-bottom: 1px solid #e4eaee;
            .iconfont {
              font-size: 28px;
              color: #546d7e;
              margin-right: 5px;
            }
          }
          .goodsContainer {
            width: 100%;

            .goodsItem {
              display: flex;
              position: relative;
              //   height: 70px;
              width: 100%;
              align-items: center;
              padding: 13px 10px 13px 15px;
              border-bottom: 1px solid #e4eaee;
              img {
                height: 70px;
                width: 70px;
              }
              .info {
                padding-left: 30px;
                width: calc(100% - 180px);
                span {
                  font-size: 12px;
                  color: #4b4b4b;
                  display: block;
                  height: 38px;
                  line-height: 38px;
                }
                span:nth-of-type(1) {
                  white-space: nowrap;
                  overflow: hidden;
                  text-overflow: ellipsis;
                }
              }
              .confirmbtn {
                position: absolute;
                height: 30px;
                right: 15px;
                color: #575757;
                font-size: 12px;
                padding: 3px 6px;
                border: 1px solid #d1d1d1;
              }
            }
          }
        }
      }
      .calendar-right {
        width: 300px;
        .calendar-title {
          color: #fff;
          text-align: center;
          background: #6ec884;
          padding: 10px;
        }
        .calendar-body {
          color: #55b46c;
          height: 140px;
          background: #f8fffa;
          border: 1px solid #cfe5d4;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          span {
            display: block;
          }
          .day {
            display: block;
            height: 66px;
            line-height: 1;
            font-size: 60px;
          }
          .week,
          .date {
            font-size: 12px;
          }
        }
        .recommend {
          margin-top: 20px;
          width: 300px;
          height: 125px;
          cursor: pointer;
          border: 1px solid #e1e1e1;
          img {
            width: 100%;
            height: 100%;
          }
        }
      }
    }
  }
}
</style>
